<template>
  <div class="consensus-activity-team">
    <c-title text="团队数据"></c-title>
    <van-tabs v-model="active" @click="get_detail">
      <van-tab v-for="item in team_data" :title="item.name" :name="item.tab_key" :key="item.tab_key"></van-tab>
    </van-tabs>
    <div class="box">
      <div class="box-item" v-for="item in list" :key="item.member_id">
        <van-image round width="2.5rem" height="2.5rem" :src="item.avatar_image" />
        <div class="box-item-right">
          <p class="nick-name">{{item.user_name}}</p>
          <div class="flex">
            <span class="span">{{item.grade_name}}</span><span v-if="item.is_supplier==1" class="span">供应商</span><span v-if="item.is_store==1" class="span">门店</span>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import { Image as VanImage } from 'vant';
export default {
  components: { VanImage },
  data() {
    return {
      team_data:[],
      active: '',
      list:[],
    };
  },
  activated() {
    this.getData();
  },
  methods: {
    getData(){
      $http.get("plugin.wise-yuan-trade.frontend.app-page.index", "", "").then(({ result, msg, data }) => {
        if (result) {
          console.log(data, "data==");
          this.team_data = data.team_data;
          this.active = data.team_data[0].tab_key;
          this.get_detail();
        } else {
          this.$toast(msg);
        }
      })
    },
    get_detail(){
      $http.get("plugin.wise-yuan-trade.frontend.app-page.detail",{tab:this.active},'').then(({result,msg,data})=>{
        if(result){
          this.list = data;
          console.log(data,"data===");
        }else{
          this.$toast(msg);
        }
      })
    },
  }
};
</script>

<style scoped lang="scss">
.consensus-activity-team {
  .flex {
    display: flex;
  }

  .span {
    font-size: 0.75rem;
    color: #f96d20;
    padding: 0.1875rem 0.375rem;
    background: rgba(249, 109, 32, 0.1);
    border-radius: 1.875rem;
    margin-right: 0.3125rem;
  }

  .nick-name {
    font-size: 0.875rem;
    font-weight: bold;
    margin-bottom: 0.3125rem;
    text-align: left;
  }

  .box-item-right {
    display: flex;
    flex-direction: column;
    margin-left: 0.3438rem;
  }

  .box {
    padding: 0.625rem 0.75rem;
  }

  .box-item {
    padding: 0.75rem;
    background: #fff;
    border-radius: 0.625rem;
    margin-bottom: 0.625rem;
    display: flex;
    align-items: center;
  }
}
</style>
